<?

/*
*
*   Excalibur Content Management System
*   Copyright © 2008 Egor "Sontan" Kuryanovich
*
*   Based on Explay Engine v2.0 by Golovdinov Alexander
*
*   Official site: www.excms.ru
*   Contact e-mail: support@excms.ru
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
*/

header ("Cache-control: no-cache");

if (file_exists("install.php")) print "<font color=red>Обнаружен файл install.php. Необходимо его удалить!</font>";

$EXCMS = "work";

include "engine/connect.php";

if ($GLOBAL_USER['user_group'] != "admin") exit;

print "<html><head><title>Загрузка файлов - Excalibur Download</title>
<style>
table { border-bottom: #cac9c7 1px solid; border-right: #cac9c7 1px solid; font-family:Arial; font-size:10pt; color:#242421; background-color: #f4f3f1 }
input { border: #b3b3b1 1px solid; border-bottom: #cac9c7 1px solid; border-right: #cac9c7 1px solid; }
.button { border: white 1px solid; border-bottom: #cac9c7 1px solid; border-right: #cac9c7 1px solid; }
</style>
</head><body>";

$dir = $_POST['dir'];
if ($dir == "") $dir = "./";

if ($_FILES['file_1']['name'] != "") {
	if (copy($_FILES['file_1']['tmp_name'],$dir.$_FILES['file_1']['name'])) print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=green>Файл <b>\"".basename($_FILES['file_1']['name'])."\"</b> загружен!<br>HTML-код: <font color=gray><b><i>".$dir.$_FILES['file_1']['name']."</i></b></font></td></tr></table>";
	else print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Ошибка загрузки файла!</td></tr></table>";
}
if ($_FILES['file_2']['name'] != "") {
	if (copy($_FILES['file_2']['tmp_name'],$dir.$_FILES['file_2']['name'])) print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=green>Файл <b>\"".basename($_FILES['file_2']['name'])."\"</b> загружен!<br>HTML-код: <font color=gray><b><i>".$dir.$_FILES['file_2']['name']."</i></b></font></td></tr></table>";
	else print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Ошибка загрузки файла!</td></tr></table>";
}
if ($_FILES['file_3']['name'] != "") {
	if (copy($_FILES['file_3']['tmp_name'],$dir.$_FILES['file_3']['name'])) print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=green>Файл <b>\"".basename($_FILES['file_3']['name'])."\"</b> загружен!<br>HTML-код: <font color=gray><b><i>".$dir.$_FILES['file_3']['name']."</i></b></font></td></tr></table>";
	else print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Ошибка загрузки файла!</td></tr></table>";
}
if ($_FILES['file_4']['name'] != "") {
	if (copy($_FILES['file_4']['tmp_name'],$dir.$_FILES['file_4']['name'])) print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=green>Файл <b>\"".basename($_FILES['file_4']['name'])."\"</b> загружен!<br>HTML-код: <font color=gray><b><i>".$dir.$_FILES['file_4']['name']."</i></b></font></td></tr></table>";
	else print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Ошибка загрузки файла!</td></tr></table>";
}
if ($_FILES['file_5']['name'] != "") {
	if (copy($_FILES['file_5']['tmp_name'],$dir.$_FILES['file_5']['name'])) print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=green>Файл <b>\"".basename($_FILES['file_5']['name'])."\"</b> загружен!<br>HTML-код: <font color=gray><b><i>".$dir.$_FILES['file_5']['name']."</i></b></font></td></tr></table>";
	else print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Ошибка загрузки файла!</td></tr></table>";
}
elseif (isset($_POST['upload']) && $_FILES['file_1']['name'] == "" && $_FILES['file_2']['name'] == "" && $_FILES['file_3']['name'] == "" && $_FILES['file_4']['name'] == "" && $_FILES['file_5']['name'] == "") print "\n<table width=100% cellspacing=0 cellpadding=2><tr><td><font color=red>Не выбран файл!</td></tr></table>";

print "<form name=upload method=post action=upload.php enctype=multipart/form-data>
<table width=100% cellcpacing=0 cellpadding=2>
<tr><td bgcolor=#dddddd style='color:white;font-weight:bold;border: #f6f5ec 1px solid;border-bottom: #a8a69d 1px solid;border-right: #a8a69d 1px solid'>Загрузка файлов<img src='images/spacer.gif' width=190 height=1><input class=button type=button onclick='location.reload()' style='font-size:8pt;height:20px' value='Обновить'> <input class=button type=button onclick='window.close()' style='font-size:8pt;height:20px' value='Закрыть'></td></tr>
<tr><td>Выберите файлы:</td></tr>
<tr><td><input style='whidth:240px;' onchange='javascript:document.getElementById(\"file_2\").style.display = \"\";' type=file name=file_1> <input onclick='javascript:document.getElementById(\"file_2\").style.display = \"\";' type=button value='+'></td></tr>
<tr id=file_2 style='display:none'><td><input style='whidth:300px;' onchange='javascript:document.getElementById(\"file_3\").style.display = \"\";' type=file name=file_2> <input onclick='javascript:document.upload.file_2.disabled=true;javascript:document.getElementById(\"file_2\").style.display = \"none\";' type=button value='-'> <input onclick='javascript:document.getElementById(\"file_3\").style.display = \"\";' type=button value='+'></td></tr>
<tr id=file_3 style='display:none'><td><input style='whidth:300px;' onchange='javascript:document.getElementById(\"file_4\").style.display = \"\";' type=file name=file_3> <input onclick='javascript:document.upload.file_3.disabled=true;javascript:document.getElementById(\"file_3\").style.display = \"none\";' type=button value='-'> <input onclick='javascript:document.getElementById(\"file_4\").style.display = \"\";' type=button value='+'></td></tr>
<tr id=file_4 style='display:none'><td><input style='whidth:300px;' onchange='javascript:document.getElementById(\"file_5\").style.display = \"\";' type=file name=file_4> <input onclick='javascript:document.upload.file_4.disabled=true;javascript:document.getElementById(\"file_4\").style.display = \"none\";' type=button value='-'> <input onclick='javascript:document.getElementById(\"file_5\").style.display = \"\";' type=button value='+'></td></tr>
<tr id=file_5 style='display:none'><td><input style='whidth:300px;' type=file name=file_5> <input onclick='javascript:document.upload.file_5.disabled=true;document.getElementById(\"file_5\").style.display = \"none\";' type=button value='-'></td></tr>
<tr><td>Выберите папку:<br>
<select name=select_ onchange='select_dir();'>
<option value=>Главная папка</option>
<option value=files/>&nbsp;&nbsp;&nbsp;&nbsp;-- файлы</option>
<option value=update/>&nbsp;&nbsp;&nbsp;&nbsp;-- обновление</option>
<optgroup label='Рисунки'>
	<option value=images/>Общие</option>
	<option value=images/articles/>Статьи</option>
<optgroup label='Система'>
	<option value=include/blocks/>Блоки</option>
	<option value=modules/>Модули</option>
		<option value=modules/articles/>&nbsp;&nbsp;&nbsp;&nbsp;-- статьи</option>
		<option value=modules/auth/>&nbsp;&nbsp;&nbsp;&nbsp;-- пользователи</option>
	<option value=themes/>Темы</option>
	<option value=admin/>Администрирование</option>
</select>
<input type=text name=dir style='width:250px'><br>
<input class=button type=submit name=upload value='Загрузить файлы!' style='margin-top:10px'>
</td></tr>
</table>
</form>
<div style='color:silver' align=right><small>Powered by Excalibur Download v 1.0</small></div>
<script>
function select_dir () {
	document.upload.dir.value = document.upload.select_.value;
}
</script>
";

?> 
